from django.http import HttpResponse
from django.shortcuts import render

# Create your views here.
def add_cookie(request):
    response = HttpResponse('设置cookie')
    max_age = 60 * 60 * 24 * 7
    response.set_cookie('username','zhiliao',max_age=max_age)
    return response

def delete_cookie(request):
    response = HttpResponse('删除cookie')
    response.delete_cookie('username')
    return response


def get_cookie(request):
    username = request.COOKIES['username']
    #username  = request.COOKIES.get('username')
    return HttpResponse(username)
def add_session(request):
    request.session['user_id'] = 'zhiliao'
    request.session.set_expiry(0)
    return HttpResponse("session add")

